#ifndef _QUAD_TREE_DEMO_STATE_
#define _QUAD_TREE_DEMO_STATE_

#include "FEApplication.h"
#include "KeyboardInputListener.h"
#include "MouseInputListener.h"

#include "FreeCameraHandler.h"

#include "StatPanel.h"
#include "TextLabel.h"

#include "QuadTreeManager.h"
#include "QuadTreeNode.h"
#include "PrimitiveLineList.h"
#include "PrimitiveCube.h"


class QuadTreeDemoState : public FEngine::FEApplication, public FEngine::KeyboardInputListener, public FEngine::MouseInputListener
{

	public:

		QuadTreeDemoState();
		~QuadTreeDemoState();
		void initialize();
		
		void updateGUI(double _elapsedTime);
		void update(double _elapsedTime);
		void render(double _elapsedTime);

		void keyPressed(int _key);
		void keyReleased(int _key);
		void mouseButtonPressed(int _button, const Vector2& _position);
		void mouseButtonReleased(int _button, const Vector2& _position);
		void mouseMoved(const Vector2& _delta);
		

	private:

		FEngine::FreeCameraHandler*					mCameraHandler;
		StatPanel*									mStatPanel;

		std::list<FEngine::TextLabel*>				mListLabels;
		
		FEngine::PrimitiveLineList*					mCenterLine;
		FEngine::PrimitiveLineList*					mAABBLine;
		std::list<FEngine::PrimitiveLineList*>		mListLines;
		FEngine::QuadTreeManager*					mQuadTreeManager;
		
		std::list<FEngine::PrimitiveCube*>			mListCubes;

		
		std::list<FEngine::QuadTreeNode*> _getChildList(FEngine::QuadTreeNode* _node);
		FEngine::PrimitiveLineList* _createLine(FEngine::QuadTreeNode* _node);

		void _placeNewObject(const Vector3& _pos);
};

#endif
